#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <peekpoke.h>
#include <string.h>
#include <conio.h>

#include "Buffers.h"
#include "Dispatcher.h"
#include "Loader.h"
#include "Drives.h"

extern void _LOADER_LOAD__, _LOADER_RUN__, _LOADER_SIZE__;
extern void _COPYFILE_LOAD__, _COPYFILE_RUN__, _COPYFILE_SIZE__;

void main(void)
{
	cursor(0);
	// Copy code from ROM to RAM that needs to always be present regardless
	// of the banked cartridge.
	memcpy(&_LOADER_RUN__, &_LOADER_LOAD__, (unsigned int)&_LOADER_SIZE__);
	memcpy(&_COPYFILE_RUN__, &_COPYFILE_LOAD__, (unsigned int)&_COPYFILE_SIZE__);

	// Initialize EAPI
	asm ("jsr __EAPIRAM_START__ + 20");

	// Load the dispatcher
	if(eapi_load("OVL.DISPATCHER") > 0)
	{
		about();

		initializeDrives();

		processCommands();
	}
}